cpLookup = {
    "-10.0": 0.16874792794783955,
    "-9.9": 0.16985049833887045,
    "-9.8": 0.17055738720598324,
    "-9.7": 0.17047675058336964,
    "-9.6": 0.17062880930380164,
    "-9.5": 0.17173295708238823,
    "-9.4": 0.1741832515174232,
    "-9.3": 0.17496583875894223,
    "-9.2": 0.17823840614328434,
    "-9.1": 0.17891311823785128,
    "-9.0": 0.18001756037367211,
    "-8.9": 0.18238828856575562,
    "-8.8": 0.18541818422621015,
    "-8.7": 0.18732127851231173,
    "-8.6": 0.188595528612019,
    "-8.5": 0.19166809721845357,
    "-8.4": 0.18989033973470404,
    "-8.3": 0.19357848980722225,
    "-8.2": 0.195212660943061,
    "-8.1": 0.1985674406526584,
    "-8.0": 0.20401430566976098,
    "-7.9": 0.2053494594581885,
    "-7.8": 0.2095001157139551,
    "-7.7": 0.2127603864858716,
    "-7.6": 0.21607609694057794,
    "-7.5": 0.21973060624595708,
    "-7.4": 0.2228248514176221,
    "-7.3": 0.22299885811455433,
    "-7.2": 0.22159517034121434,
    "-7.1": 0.2253474128373214,
    "-7.0": 0.22700275966883976,
    "-6.9": 0.2277978270416834,
    "-6.8": 0.23198254537369023,
    "-6.7": 0.23592594616253237,
    "-6.6": 0.24197398088661215,
    "-6.5": 0.24743721350483228,
    "-6.4": 0.2504634951693775,
    "-6.3": 0.25389828445048646,
    "-6.2": 0.2553693799097443,
    "-6.1": 0.2574747677153313,
    "-6.0": 0.26099610941165985,
    "-5.9": 0.26359484469524885,
    "-5.8": 0.26692516804140987,
    "-5.7": 0.269205898445802,
    "-5.6": 0.2716602975482676,
    "-5.5": 0.2762577909143481,
    "-5.4": 0.27686670371314326,
    "-5.3": 0.2811527494908349,
    "-5.2": 0.2842962444080047,
    "-5.1": 0.28868260131133583,
    "-5.0": 0.2914459750278813,
    "-4.9": 0.29552500948265914,
    "-4.8": 0.29889111624248266,
    "-4.7": 0.30275330907688625,
    "-4.6": 0.30483684697544633,
    "-4.5": 0.3087308954422261,
    "-4.4": 0.3119607377503364,
    "-4.3": 0.3149431542506458,
    "-4.2": 0.31853131804955126,
    "-4.1": 0.320778152372042,
    "-4.0": 0.32500585429582063,
    "-3.9": 0.3287550205647155,
    "-3.8": 0.3302152905962328,
    "-3.7": 0.3337414440782651,
    "-3.6": 0.3371096329087784,
    "-3.5": 0.3408372806176929,
    "-3.4": 0.3430467389812629,
    "-3.3": 0.345358794898586,
    "-3.2": 0.3488968896485116,
    "-3.1": 0.35237319918137733,
    "-3.0": 0.354602162593592,
    "-2.9": 0.35921288506416393,
    "-2.8": 0.3620978187487768,
    "-2.7": 0.36570889434391574,
    "-2.6": 0.36896483582772577,
    "-2.5": 0.3738375709360098,
    "-2.4": 0.37755946149735364,
    "-2.3": 0.38083501393471353,
    "-2.2": 0.3841356210618174,
    "-2.1": 0.38833097169521236,
    "-2.0": 0.3913569664390527,
    "-1.9": 0.39637664590926824,
    "-1.8": 0.4006706381318188,
    "-1.7": 0.40568723118901173,
    "-1.6": 0.4112309032143989,
    "-1.5": 0.4171285506703859,
    "-1.4": 0.422533096069275,
    "-1.3": 0.4301262113278628,
    "-1.2": 0.4371930420830884,
    "-1.1": 0.44297556987180564,
    "-1.0": 0.4456913220302985,
    "-0.9": 0.4524847690277852,
    "-0.8": 0.4589667426852546,
    "-0.7": 0.46660356893847554,
    "-0.6": 0.47734553584312966,
    "-0.5": 0.4838742651753062,
    "-0.4": 0.4949662422107537,
    "-0.3": 0.5052075551297714,
    "-0.2": 0.5134173311516534,
    "-0.1": 0.5243603487770374,
    "-0.0": 0.5606402112975601,
    "0.1": 0.5295389291852245,
    "0.2": 0.5664296189371014,
    "0.3": 0.5748717155242605,
    "0.4": 0.5869360163496304,
    "0.5": 0.5921709270831235,
    "0.6": 0.6012651707026009,
    "0.7": 0.6088638279243903,
    "0.8": 0.6153816495064385,
    "0.9": 0.6213113677421394,
    "1.0": 0.6271095095579187,
    "1.1": 0.632804166473034,
    "1.2": 0.6381911052846212,
    "1.3": 0.6442037744916549,
    "1.4": 0.649365491330027,
    "1.5": 0.6541269394628821,
    "1.6": 0.6593775707102116,
    "1.7": 0.6642844357446305,
    "1.8": 0.6680323879474359,
    "1.9": 0.6719097160994534,
    "2.0": 0.6748374005101319,
    "2.1": 0.6783363422342483,
    "2.2": 0.6801467867275195,
    "2.3": 0.684829276628467,
    "2.4": 0.6867513620895516,
    "2.5": 0.6905527274606579,
    "2.6": 0.6926332976777145,
    "2.7": 0.6952680187678887,
    "2.8": 0.7001656575385784,
    "2.9": 0.7010142788018504,
    "3.0": 0.7047537668053925,
    "3.1": 0.7073295468984271,
    "3.2": 0.7106392738949507,
    "3.3": 0.7116862871579852,
    "3.4": 0.7149981105354425,
    "3.5": 0.7168150290640533,
    "3.6": 0.7181645290803663,
    "3.7": 0.7215706104143079,
    "3.8": 0.7257548871790502,
    "3.9": 0.7266799478667236,
    "4.0": 0.7312566255649167,
    "4.1": 0.7338343990993276,
    "4.2": 0.7363492332937249,
    "4.3": 0.7374945601492073,
    "4.4": 0.7413387385114591,
    "4.5": 0.7466896678519318,
    "4.6": 0.7461156227069248,
    "4.7": 0.7500348334958896,
    "4.8": 0.7525591569082364,
    "4.9": 0.7567349424376287,
    "5.0": 0.7596581998583797,
    "5.1": 0.7621623413577621,
    "5.2": 0.7644432506942895,
    "5.3": 0.7668438338565464,
    "5.4": 0.7697341715213551,
    "5.5": 0.7718264040129471,
    "5.6": 0.774903252738822,
    "5.7": 0.777338112750803,
    "5.8": 0.7782543748612702,
    "5.9": 0.7815446531238023,
    "6.0": 0.7817240741095305,
    "6.1": 0.7843444714897749,
    "6.2": 0.7879064312243436,
    "6.3": 0.7894336918448414,
    "6.4": 0.7906807160826923,
    "6.5": 0.7958175057898639,
    "6.6": 0.799001778895725,
    "6.7": 0.8059773285734155,
    "6.8": 0.8073085278260186,
    "6.9": 0.8079169497726442,
    "7.0": 0.8094553564231399,
    "7.1": 0.812049156586624,
    "7.2": 0.8080964608399982,
    "7.3": 0.8089371589128438,
    "7.4": 0.811884066397279,
    "7.5": 0.8139355726992591,
    "7.6": 0.8176447870147248,
    "7.7": 0.8205118056812014,
    "7.8": 0.8239310183322626,
    "7.9": 0.8246215704824976,
    "8.0": 0.8282444028473858,
    "8.1": 0.8307566922119521,
    "8.2": 0.8299970989266028,
    "8.3": 0.8329910434137715,
    "8.4": 0.8348790035853562,
    "8.5": 0.8354299179013772,
    "8.6": 0.838042734118834,
    "8.7": 0.8386288753155167,
    "8.8": 0.8403357337021318,
    "8.9": 0.8438203836486884,
    "9.0": 0.8438217313242881,
    "9.1": 0.8451134380453753,
    "9.2": 0.8456384082100551,
    "9.3": 0.844182520663178,
    "9.4": 0.8463847100484717,
    "9.5": 0.8479706716538067,
    "9.6": 0.8511321531494442,
    "9.7": 0.8506127153603494,
    "9.8": 0.8490128260556276,
    "9.9": 0.8522167487684729,
    "10.0": 0.8518353443061348
}

cpLookup = {float(k) : wr for k, wr in cpLookup.items()}

def cp_to_winrate(cp, allow_nan = False):
    try:
        cp = int(float(cp) * 10) / 10
    except OverflowError:
        return float("nan")
    except ValueError:
        #This can be caused by a bunch of other things too so this option is dangerous
        if allow_nan:
            return float("nan")
        else:
            raise
    try:
        return cpLookup[cp]
    except KeyError:
        return float("nan")
